/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.googlecode.mailnet.emf.netmodel.impl;

import com.googlecode.mailnet.emf.netmodel.NetmodelPackage;
import com.googlecode.mailnet.emf.netmodel.QueueModel;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Queue Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.QueueModelImpl#getWeight <em>Weight</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.QueueModelImpl#getLimit <em>Limit</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.QueueModelImpl#isStrictlyPrioritized <em>Strictly Prioritized</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class QueueModelImpl extends EObjectImpl implements QueueModel {
	/**
	 * The default value of the '{@link #getWeight() <em>Weight</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWeight()
	 * @generated
	 * @ordered
	 */
	protected static final int WEIGHT_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getWeight() <em>Weight</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWeight()
	 * @generated
	 * @ordered
	 */
	protected int weight = WEIGHT_EDEFAULT;

	/**
	 * The default value of the '{@link #getLimit() <em>Limit</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLimit()
	 * @generated
	 * @ordered
	 */
	protected static final int LIMIT_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getLimit() <em>Limit</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLimit()
	 * @generated
	 * @ordered
	 */
	protected int limit = LIMIT_EDEFAULT;

	/**
	 * The default value of the '{@link #isStrictlyPrioritized() <em>Strictly Prioritized</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isStrictlyPrioritized()
	 * @generated
	 * @ordered
	 */
	protected static final boolean STRICTLY_PRIORITIZED_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isStrictlyPrioritized() <em>Strictly Prioritized</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isStrictlyPrioritized()
	 * @generated
	 * @ordered
	 */
	protected boolean strictlyPrioritized = STRICTLY_PRIORITIZED_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected QueueModelImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return NetmodelPackage.Literals.QUEUE_MODEL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getWeight() {
		return weight;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setWeight(int newWeight) {
		int oldWeight = weight;
		weight = newWeight;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.QUEUE_MODEL__WEIGHT, oldWeight, weight));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getLimit() {
		return limit;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLimit(int newLimit) {
		int oldLimit = limit;
		limit = newLimit;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.QUEUE_MODEL__LIMIT, oldLimit, limit));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isStrictlyPrioritized() {
		return strictlyPrioritized;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStrictlyPrioritized(boolean newStrictlyPrioritized) {
		boolean oldStrictlyPrioritized = strictlyPrioritized;
		strictlyPrioritized = newStrictlyPrioritized;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.QUEUE_MODEL__STRICTLY_PRIORITIZED, oldStrictlyPrioritized, strictlyPrioritized));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case NetmodelPackage.QUEUE_MODEL__WEIGHT:
				return new Integer(getWeight());
			case NetmodelPackage.QUEUE_MODEL__LIMIT:
				return new Integer(getLimit());
			case NetmodelPackage.QUEUE_MODEL__STRICTLY_PRIORITIZED:
				return isStrictlyPrioritized() ? Boolean.TRUE : Boolean.FALSE;
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case NetmodelPackage.QUEUE_MODEL__WEIGHT:
				setWeight(((Integer)newValue).intValue());
				return;
			case NetmodelPackage.QUEUE_MODEL__LIMIT:
				setLimit(((Integer)newValue).intValue());
				return;
			case NetmodelPackage.QUEUE_MODEL__STRICTLY_PRIORITIZED:
				setStrictlyPrioritized(((Boolean)newValue).booleanValue());
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case NetmodelPackage.QUEUE_MODEL__WEIGHT:
				setWeight(WEIGHT_EDEFAULT);
				return;
			case NetmodelPackage.QUEUE_MODEL__LIMIT:
				setLimit(LIMIT_EDEFAULT);
				return;
			case NetmodelPackage.QUEUE_MODEL__STRICTLY_PRIORITIZED:
				setStrictlyPrioritized(STRICTLY_PRIORITIZED_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case NetmodelPackage.QUEUE_MODEL__WEIGHT:
				return weight != WEIGHT_EDEFAULT;
			case NetmodelPackage.QUEUE_MODEL__LIMIT:
				return limit != LIMIT_EDEFAULT;
			case NetmodelPackage.QUEUE_MODEL__STRICTLY_PRIORITIZED:
				return strictlyPrioritized != STRICTLY_PRIORITIZED_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (weight: ");
		result.append(weight);
		result.append(", limit: ");
		result.append(limit);
		result.append(", strictlyPrioritized: ");
		result.append(strictlyPrioritized);
		result.append(')');
		return result.toString();
	}

} //QueueModelImpl
